--[[
--
--  crp_minimalst core
--
--]]

local crp = CreateFrame("Frame","crp",UIParent);

function crp:RegisterPanel(framename)
 local f = framename;
 local t = framename:CreateTexture(nil, 'BORDER')
 if f.framestrata ~= nil then
  f:SetFrameStrata(f.framestrata)
 else
  f:SetFrameStrata("BACKGROUND");
 end
 f:SetParent(f.parent)
 f:SetFrameLevel(0)
 f:SetWidth(framename.width)
 f:SetHeight(framename.height)
 if f.Repeat == "true" or f.Repeat == true or f.Repeat == 1 or f.Repeat == "1" then 
  f.Repeat = true
 else
  f.Repeat = false
 end
 f:SetBackdrop({bgFile = f.texture, 
                                            edgeFile = f.edge, 
                                            tile = f.Repeat, tileSize = f.tilesize, edgeSize = f.edgesize, 
                                            insets = { left = f.edgeinsets, right = f.edgeinsets, top = f.edgeinsets, bottom = f.edgeinsets }});
 if framename.color[4] ~= nil then
 f:SetBackdropColor(tonumber(framename.color[1]),tonumber(framename.color[2]),tonumber(framename.color[3]),tonumber(framename.color[4]))
 else
 f:SetBackdropColor(tonumber(framename.color[1]),tonumber(framename.color[2]),tonumber(framename.color[3]),1.0)
 end
 t:SetAllPoints(f)
 f:Show();
end

function crp:stresstest(max)
 for i=1,max do
  
local frame = CreateFrame("Frame",nil, UIParent) -- dont change
frame.parent = "ChatFrame1"
frame.texture = "interface/buttons/white8x8"; -- filepath
frame.color = {0, 1, 0, 0.5}; -- r, g, b, a
-- frame1:SetPoint("CENTER",UIParent); -- AnchorTo, RelativeTo[, RelativePoint][, OffsetX][, OffsetY]
frame:SetPoint("TOPRIGHT",ChatFrame1,"TOPRIGHT")
frame:SetPoint("BOTTOMRIGHT",ChatFrame1,"BOTTOMRIGHT")
-- frame1.edge = "Interface/Tooltips/UI-Tooltip-Border" -- filepath
frame.edgeinsets = -4; -- change inner space
frame.width = getglobal(frame.parent):GetWidth()/2; -- width
frame.height = getglobal(frame.parent):GetHeight(); -- height
crp:RegisterPanel(frame) -- dont change
 end
end 